<html>
<head><meta charset="utf-8"><title>note_without_err on running lto for unsupported crate-type · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/note_without_err.20on.20running.20lto.20for.20unsupported.20crate-type.html">note_without_err on running lto for unsupported crate-type</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224158301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/note_without_err%20on%20running%20lto%20for%20unsupported%20crate-type/near/224158301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> csmoe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/note_without_err.20on.20running.20lto.20for.20unsupported.20crate-type.html#224158301">(Jan 27 2021 at 09:41)</a>:</h4>
<p>Given a crate in a workspace, whose toml is:</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="k">[lib]</span>
<span class="n">crate-type</span> <span class="o">=</span> <span class="k">[ "rlib", "cdylib" ]</span>
</code></pre></div>
<p>it's ok to compile this crate as a dependencies with <code>-Clto=fat</code>, but if I try to compile this crate to produce a single dylib with lto, <a href="https://github.com/rust-lang/rust/blob/78e22069d018e83915201c8a218a0a94227f6420/compiler/rustc_codegen_llvm/src/back/lto.rs#L93">the compiler exit immediately</a>:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">lto</span><span class="w"> </span><span class="n">can</span><span class="w"> </span><span class="n">only</span><span class="w"> </span><span class="n">be</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">executables</span><span class="p">,</span><span class="w"> </span><span class="n">cdylibs</span><span class="w"> </span><span class="n">and</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="n">library</span><span class="w"> </span><span class="n">outputs</span><span class="s">"</span>
</code></pre></div>
<p>Is it okay to make rustc to just skip the lto action on  <code>rlib</code> crate-type and emit a note without failing the compilation?</p>



<a name="224158495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/note_without_err%20on%20running%20lto%20for%20unsupported%20crate-type/near/224158495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/note_without_err.20on.20running.20lto.20for.20unsupported.20crate-type.html#224158495">(Jan 27 2021 at 09:43)</a>:</h4>
<p>That would require duplicating codegen. Once for the <code>rlib</code> without LTO and once for the <code>cdylib</code> with LTO. That would require non-neglectable changes.</p>



<a name="224158718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/note_without_err%20on%20running%20lto%20for%20unsupported%20crate-type/near/224158718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> csmoe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/note_without_err.20on.20running.20lto.20for.20unsupported.20crate-type.html#224158718">(Jan 27 2021 at 09:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/131828-t-compiler/topic/note_without_err.20on.20running.20lto.20for.20unsupported.20crate-type/near/224158495">said</a>:</p>
<blockquote>
<p>That would require duplicating codegen. Once for the <code>rlib</code> without LTO and once for the <code>cdylib</code> with LTO. That would require non-neglectable changes.</p>
</blockquote>
<p>thanks</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>